package com.heima.controller;

import com.heima.pojo.PageBean;
import com.heima.pojo.VmType;
import com.heima.pojo.dto.PartnerQueryParamDto;
import com.heima.service.VmTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/vmType")
@Api(value = "设备管理")
@Slf4j
public class VmTypeController {
    @Autowired
    private VmTypeService vmService;

    @GetMapping("/search")
    @ApiOperation("设备分页查询")
    public PageBean selectVmList( PartnerQueryParamDto  vmDto){
        log.info("进来的name是：{}",vmDto.getName());
       return vmService.selectVmList(vmDto);
    }
    @PostMapping
    @ApiOperation("新增设备")
    public Boolean addVmType(@RequestBody VmType vmType){
        log.info("要添加的VMtype是：{}",vmType);
        return vmService.addVmType(vmType);
    }
    @PutMapping("/{typeId}")
    @ApiOperation("修改")
    public Boolean updateVmType (@PathVariable int typeId,@RequestBody VmType vmType){
        vmType.setTypeId(typeId);
        log.info("要修改的vmType为：{}",vmType);
        return vmService.updateVmType(vmType);
    }
    @DeleteMapping("{typeId}")
    @ApiOperation("删除设备")
    public Boolean deleteVmType (@PathVariable int typeId){
        log.info("要删除的vmTypeId为：{}",typeId);
        return vmService.deleteVmType(typeId);
    }
}
